package org.embedchat.database.dao;

import java.util.List;

import org.embedchat.database.ItemNotFoundException;
import org.embedchat.database.UserDAOInterface;
import org.embedchat.entity.User;

public class UserDAOImpl extends GenericHibernateDAO<User, Long, GenericUserDAO> implements UserDAOInterface, GenericUserDAO {

	public User findUser(String login, String password) throws ItemNotFoundException {
    	User example = new User();
    	example.setLoginName(login);
    	example.setLoginPassword(password);
    	String[] excludedParameters = new String[3];
    	List<User> foundItems = findByExample(example, excludedParameters);
		if (foundItems.size() > 0) {
			return foundItems.get(0);
		}
		throw new ItemNotFoundException();
	}
}
